package com.linkvin.ec.hcs.service.sysadmin.impl;

import com.linkvin.ec.hcs.dao.mapper.sysadmin.OrgMapper;
import com.linkvin.ec.hcs.dao.model.sysadmin.Org;
import com.linkvin.ec.hcs.service.sysadmin.OrgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by zhaoguixin on 2017/12/10.
 */
@Service
public class OrgServiceImpl implements OrgService {

    @Autowired
    private OrgMapper orgMapper;

    @Override
    public int addOrg(Org org) {
        //TODO 非空、重复校验
        return orgMapper.insert(org);
    }

    @Override
    public int updateOrg(Org org) {
        return orgMapper.updateById(org);
    }

    @Override
    public int deleteOrg(List<Integer> orgIds) {
        return orgMapper.deleteBatchIds(orgIds);
    }

    @Override
    public List<Org> listAllOrg() {
        return orgMapper.selectList(null);
    }

    @Override
    public List<Org> listOrgByPid(Integer parentId) {
        Map<String,Object> map = new HashMap<>();
        map.put("parent",parentId);
        return orgMapper.selectByMap(map);
    }
}
